package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFile;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface CategoryMapper {
    //1:分类分页查询
    Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);

    //2:新增分类
    @Insert("insert into category (id, type, name, sort, status, create_time, update_time, create_user, update_user)" +
            "values (#{id},#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFile(value = OperationType.INSERT)
    void add(Category category);

    //3：启用禁用分类
    @AutoFile(value = OperationType.UPDATE)
    void update(Category category);

    //4:根据ID删除分类
    @Delete("delete  from category where id=#{id}")
    void deleteById(Long id);

    //5：根据类型查询分类

    List<Category> find(Integer type);

    //6：修改分类

}
